<script>
import * as echarts from 'echarts';
export default {
  name: "line-chart",
  mounted() {
    this.init();
  },
  methods: {
    init() {
      let dom = document.getElementById("lineDom");
      let chart = echarts.init(dom);
      chart.setOption(this.getOptions());
    },
    getOptions() {
      return {
        title: {
          text: '收支记录'
        },
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['收入', '支出']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['16日', '15日', '14日', '13日', '12日', '11日', '10日']
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '收入',
            type: 'line',
            stack: 'Total',
            data: [120, 132, 101, 134, 90, 230, 210]
          },
          {
            name: '支出',
            type: 'line',
            stack: 'Total',
            data: [220, 182, 191, 234, 290, 330, 310]
          }
        ]
      }
    },
  }
}
</script>

<template>
  <div>
    <div id="lineDom" style="width: 100%;height: 300px"></div>
  </div>
</template>

<style scoped lang="scss">

</style>
